<script>
	import Vue from 'vue'
	export default {
		onLaunch: function() {
			if (!this.$store.state.userInfo) {
			    uni.redirectTo({
			    	url: '/pages/login/login'
			    });
			}
			// 处理推送消息
			this.handlePush()
			// 初始化系统
			this.initSystem()
		},
		onShow: function() {
			// 判断网络连接
			uni.onNetworkStatusChange(function (res) {
				if(!res.isConnected) {
					uni.showToast({
						icon: 'none',
						title:"请检查网络连接",
						duration: 5000,
						position: 'top'
					})
				}
			})
		},
		onHide: function() {
			// console.log('App Hide')
		},
		// 捕获 app error
		onError(err) {
			// console.log(err)
		},
		methods: {
			/**
			 * 处理推送消息
			 */
			handlePush() {
				// #ifdef APP-PLUS
				var pinf = plus.push.getClientInfo();
				var cid = pinf.clientid; //客户端标识
				const _self = this
				const _handlePush = function(message) {
					_self.$store.commit('saveInfo', JSON.parse(message.content))
					setTimeout(()=> {
						uni.redirectTo()({
							url: '/pages/home/index?type=infos',
							
						})
					}, 1000)
				}
				// 事件处理
				plus.push.addEventListener('click', _handlePush)
				plus.push.addEventListener('receive', _handlePush)
				// #endif
			},
			/**
			 * 初始化系统
			 */
			initSystem() {
				uni.getSystemInfo({
					success: function(e) {
						// #ifndef MP
						Vue.prototype.StatusBar = e.statusBarHeight;
						if (e.platform == 'android') {
							Vue.prototype.CustomBar = e.statusBarHeight + 50;
						} else {
							Vue.prototype.CustomBar = e.statusBarHeight + 45;
						};
						// #endif
				
						// #ifdef MP-WEIXIN
						Vue.prototype.StatusBar = e.statusBarHeight;
						let custom = wx.getMenuButtonBoundingClientRect();
						Vue.prototype.Custom = custom;
						Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
						// #endif		
				
						// #ifdef MP-ALIPAY
						Vue.prototype.StatusBar = e.statusBarHeight;
						Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
						// #endif
					}
				})
				// #ifdef APP-PLUS
				// 锁定屏幕方向
				plus.screen.lockOrientation('portrait-primary'); //锁定
				// plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
				// 	console.log(wgtinfo.versionCode);
				// 	console.log(wgtinfo.version);   //版本号
				// })
				// #endif
			}
		}
	}
</script>

<style>
	@import "colorui/main.css";
	@import "colorui/icon.css";
	@import "colorui/iconfont/iconfont.css";
	@import url('@/common/uni.css');
	
	.nav-list {
		display: flex;
		flex-wrap: wrap;
		padding: 30upx 30upx 30upx;
		justify-content: space-between;
	}
	
	.nav-li {
		padding: 50upx 50upx;
		border-radius: 12upx;
		margin: 0 0 40upx 0;
		background-image: url(./static/img/card-bg.png);
		box-shadow: 0px 6px 9px 0px rgba(0,0,0,0.16); 
		background-size: cover;
		background-position: center;
		position: relative;
		z-index: 1;
		display: flex;
		align-items: center;
	}
	
	.nav-li::after {
		content: "";
		position: absolute;
		z-index: -1;
		background-color: inherit;
		width: 100%;
		height: 100%;
		left: 0;
		bottom: -10%;
		border-radius: 10upx;
		opacity: 0.2;
		transform: scale(0.9, 0.9);
	}
	
	.nav-li.cur {
		color: #fff;
		background: rgb(94, 185, 94);
		box-shadow: 4upx 4upx 6upx rgba(94, 185, 94, 0.4);
	}
	
	.nav-li text {
		/* position: absolute;
		left: 40upx;
		top: 30upx; */
		margin-left: 10upx;
		margin-right: 30upx;
		color: #3088f4;
		font-size: 52upx;
		width: 60upx;
		height: 60upx;
		text-align: center;
		line-height: 60upx;
	}
	
	.nav-title {
		font-size: 34upx;
		font-weight: 700;
		text-align: right;
		color: rgba(0,0,0,0.75);
	}
	
/* 	.nav-title::first-letter {
		font-size: 40upx;
		margin-right: 4upx;
	} */
	
	.nav-name {
		font-size: 28upx;
		text-transform: Capitalize;
		margin-top: 20upx;
		position: relative;
	}
	
	.nav-name::before {
		content: "";
		position: absolute;
		display: block;
		width: 40upx;
		height: 6upx;
		background: #fff;
		bottom: 0;
		right: 0;
		opacity: 0.5;
	}
	
	.nav-name::after {
		content: "";
		position: absolute;
		display: block;
		width: 100upx;
		height: 1px;
		background: #fff;
		bottom: 0;
		right: 40upx;
		opacity: 0.3;
	}
	
	.nav-name::first-letter {
		font-weight: bold;
		font-size: 36upx;
		margin-right: 1px;
	}
	
	.text-light {
		font-weight: 300;
	}
	
	@keyframes show {
		0% {
			transform: translateY(-50px);
		}
	
		60% {
			transform: translateY(40upx);
		}
	
		100% {
			transform: translateY(0px);
		}
	}
	
	@-webkit-keyframes show {
		0% {
			transform: translateY(-50px);
		}
	
		60% {
			transform: translateY(40upx);
		}
	
		100% {
			transform: translateY(0px);
		}
	}
</style>
